<?php
namespace app\servercomment\model;

use \app\manage\model\BaseModel;

class Comment extends BaseModel
{
	protected $name = 'comment';
    protected $connection = 'db_config_comment';
    protected $dateFormat = 'Y-m-d';

    public function setObjContentAttr($value, $data)
    {
        return json_encode($data['obj_content']);
    }
   
    public function getObjContentAttr($value,$data)
    {
        return json_decode($data['obj_content']);
    }

    public function setOrtherInfoAttr($value, $data)
    {
        return json_encode($data['orther_info']);
    }
   
    public function getOrtherInfoAttr($value,$data)
    {
        return json_decode($data['orther_info']);
    }

    public function setAvgScoreAttr($value, $data)
    {
        $total = array_sum($data['orther_info']['score']);
        return bcdiv( $total, count($data['orther_info']['score']), 1 );
    }
  
}